#%RAML 1.0 Library
uses:
  strings: stringTypes.raml
  pragma: pragma.raml
types:
  ReadinessCheck:
    type: object
    description: |
      Query these readiness checks to determine if a task is ready to serve requests.
    properties:
      name?:
        type: string
        description: The name used to identify this readiness check
        minLength: 1
        default: readinessCheck
      protocol?:
        type: strings.HttpScheme
        default: HTTP
      path?:
        type: strings.Path
        description: |
          Path to endpoint exposed by the task that will provide readiness status.
        minLength: 1
        example: /path/to/health.
        default: /
      portName?:
        type: strings.LegacyName
        description: |
          Name of the port to query as described in the portDefinitions or portMappings.
        example: http-api
        default: http-api
      intervalSeconds?:
        type: integer
        format: int32
        minimum: 0
        default: 30
        description: |
          Number of seconds to wait between readiness checks.
      timeoutSeconds?:
        type: integer
        format: int32
        minimum: 1
        default: 10
        description: |
          Number of seconds after which a health check is considered a failure
          regardless of the response.
          Must be smaller than intervalSeconds.
      httpStatusCodesForReady?:
        type: array
        (pragma.forceOptional):
        items:
          type: integer
          format: int32
          minimum: 100
          maximum: 999
        description: The HTTP(s) status codes to treat as 'ready'
        usage: force-optional because we can't specify defaults in RAML yet and there is a minLength requirement
        uniqueItems: true
        minItems: 1
      preserveLastResponse?:
        type: boolean
        description: |
          If and only if true, preserve the last readiness check responses and
          expose them in the API as part of a deployment.
        default: false

  ReadinessCheckHttpResponse:
    type: object
    description: The last HTTP response received for the given readiness check
    properties:
      status:
        type: integer
        format: int32
        description: The HTTP status code returned (ex. 200)
      contentType:
        type: string
        description: The value of the Content-Type header in the response
      body:
        type: string
        description: The raw payload of body of the HTTP response

  TaskReadinessCheckResult:
    type: object
    properties:
      name:
        type: string
        description: The name of the readiness check, as defined by the user
      taskId:
        type: strings.InstanceId
        description: The name of the instance
      ready:
        type: boolean
        description: If `true` this readiness check is succesful on the given task
      lastResponse?:
        type: ReadinessCheckHttpResponse
        description: The last HTTP response received for this readiness check
